home *** CD-ROM | disk | FTP | other *** search
- property spr, mem
- property interessados
- property velMax, velMin, puloMax
- property linhaAtual, linhaMax
- property numLinhas
- property alturaLinha, linhasJanela
- property ultimoScroll, lastOut
- property areaSensivel
- property ligado, modificouCursor
- property numCursor
-
- on getPropertyDescriptionList
- set p_list = [ ¬
- #alturaLinha: [ #comment: "Altura (em pixels) de cada linha (0 p/ nao alterar)", ¬
- #format: #integer,¬
- #default: 16 ],¬
- #velMax: [ #comment: "Velocidade maxima(pix/s)", ¬
- #format: #integer,¬
- #default: 96 ],¬
- #velMin: [ #comment: "Velocidade minima(pix/s)", ¬
- #format: #integer,¬
- #default: 16 ],¬
- #puloMax: [ #comment: "Maior pulo do scroll (em pixels)", ¬
- #format: #integer,¬
- #default: 16 ],¬
- #interessados: [ #comment: "Sprites que se interessam pelo scroll:", ¬
- #format: #list, ¬
- #default: [] ],¬
- #areaSensivel: [ #comment: "Area sensivel (em pixels)", ¬
- #format: #integer,¬
- #default: 48 ]¬
- ]
- return p_list
- end
-
- on beginSprite me
- set spr = the spriteNum of me
- set mem = the member of sprite spr
- set linhaAtual = 0
- set numLinhas = the lineCount of member mem
- if alturaLinha = 0 then
- set alturaLinha = lineheight(mem, 1)
- else
- set the lineHeight of member mem to alturaLinha
- end if
- set linhasJanela = the height of sprite spr
- set linhaMax = numLinhas
- set linhaMax = numLinhas * alturaLinha - linhasJanela / 2
- if linhaMax < 0 then set linhaMax = 0
- set the scrollTop of member mem to 0
- set ultimoScroll = the timer
- set lastOut = true
- -- set the visibility of sprite spr to false
- -- set ligado = false
- set modificouCursor = false
- set numCursor = 1
- end
-
- on cleanSprite me
- set the visibility of sprite (the spriteNum of me) to true
- end
-
- on idleSprite me
- global gMustUpdate
-
- -- if not ligado then
- -- set the visibility of sprite spr to true
- -- set ligado = true
- -- set gMustUpdate = true
- -- end if
- if not the visible of sprite spr then return
-
- -- Verifica se mouse passa por cima do texto
- global gCritico
- if not rollOver(spr) or gCritico > 0 then
- set lastOut = true
- if modificouCursor then
- cursor -1
- set modificouCursor = false
- end if
- return
- end if
-
-
- global gCritico, gMustUpdate
- set y = the mouseV
-
- -- Calcula velocidade conforme posicao do mouse
- set v = 0
- set y = y - the locV of sprite spr
- if (y < areaSensivel) then
- set v = -( (areaSensivel - y) * (velMax - velMin) / areaSensivel + velMin )
- else
- set y = (the height of sprite spr) - y
- if (y < areaSensivel) then
- set v = (areaSensivel - y) * (velMax - velMin) / areaSensivel + velMin
- end if
- end if
- if v = 0 then
- if not lastOut then set lastOut = true
- if modificouCursor then
- cursor -1
- set modificouCursor = false
- end if
- return
- end if
-
- -- Calcula delta de linhas
- if lastOut then
- set lastOut = false
- set ultimoScroll = the timer
- return
- end if
- set dl = (the timer - ultimoScroll) * v / 60
- if dl > 0 and linhaAtual = linhaMax then set dl = 0
- else if dl < 0 and linhaAtual = 0 then set dl = 0
-
- if dl = 0 then
- if modificouCursor then
- cursor -1
- set modificouCursor = false
- end if
- return
- end if
-
- if dl > 0 then
- cursor [the number of member ("CursorBaixo" & numCursor),¬
- the number of member "CursorMask"]
- set numCursor = 3 - numCursor
- set modificouCursor = true
- if dl > puloMax then
- set dl = puloMax
- end if
- else
- cursor [the number of member ("CursorCima" & numCursor),¬
- the number of member "CursorMask"]
- set numCursor = 3 - numCursor
- set modificouCursor = true
- if dl < - puloMax then
- set dl = - puloMax
- end if
- end if
- set ultimoScroll = the timer
-
- -- Calcula nova linha
- set l = linhaAtual + dl
- if l < 0 then set l = 0
- else if l > linhaMax then
- set dl = dl + linhaMax
- set l = linhaMax
- end if
-
- if l <> linhaAtual then
- set the scrollTop of member mem to l
- set gMustUpdate = true
- repeat with i = 1 to count(interessados)
- sendSprite(getAt(interessados,i), #scrollLinha, l - linhaAtual)
- end repeat
- set linhaAtual = l
- end if
- end
-
- on mouseUp me
- set y = the mouseV
- set dl = 0
-
- -- Calcula velocidade conforme posicao do mouse
- set y = y - the locV of sprite spr
- if (y < areaSensivel and linhaAtual > 0) then
- puppetSound 2, "Warp1"
- -- Scroll page down
- set dl = - linhasJanela
- -- termina if logo acima
- else
- set y = (the height of sprite spr) - y
- if (y < areaSensivel and linhaAtual < linhaMax) then
- puppetSound 2, "Warp2"
- -- Scroll page up
- set dl = + linhasJanela
- end if
- end if
-
- if dl = 0 then return
-
- -- Calcula nova linha
- set l = linhaAtual + dl
- if l < 0 then set l = 0
- else if l > linhaMax then
- set l = linhaMax
- end if
-
- if l <> linhaAtual then
- set the scrollTop of member mem to l
- repeat with i = 1 to count(interessados)
- sendSprite(getAt(interessados,i), #scrollLinha, l - linhaAtual)
- end repeat
- set linhaAtual = l
- end if
-
- updateStage
-
- stopEvent
- end